﻿Public Class WF2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub BtnEntrar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BtnEntrar.Click
        If RadioButtonList1.SelectedItem.Value = "Despachante" Then
            Dim objADespLogado As New Despachante
            Dim objADespDAO As New DespachateDAO

            objADespLogado = objADespDAO.LoginDesp(TbLogin.Text.ToString, tbSenha.Text.ToString)

            If objADespLogado IsNot Nothing Then
                If objADespLogado.StatusDesp = "Ativo" Then
                    Session.Add("DespLogado", objADespLogado)
                    Response.Redirect("~/ScreensDesp/WfPrincipalDesp.aspx")
                Else
                    Response.Redirect("~/PAGE_ERRO_LOGIN/CotatoADM.aspx")
                End If

            Else
                Label1.Text = "Usuario não encontrado, Tente novamente !"
                TbLogin.Text = ""
                tbSenha.Text = ""
            End If
            End If

        If RadioButtonList1.SelectedItem.Value = "Administrador" Then
            Dim objAdmLogado As New Adm
            Dim objAdmpDAO As New AdmDAO
            objAdmLogado = objAdmpDAO.LoginAdm(TbLogin.Text.ToString, tbSenha.Text.ToString)

            If objAdmLogado IsNot Nothing Then
                Session.Add("AdmLogado", objAdmLogado)
                Response.Redirect("~/Screens/WfPrincipalAdm.aspx")

            Else
                Label1.Text = "Usuario não encontrado, Tente novamente !"
                TbLogin.Text = ""
                tbSenha.Text = ""
            End If
        End If
    End Sub
End Class